#!/usr/bin/env bash
set -euo pipefail
APP_BUNDLE="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
RELEASE_DIR="$(cd "${APP_BUNDLE}/.." && pwd)"
RESOURCES_DIR="${APP_BUNDLE}/Contents/Resources"
mkdir -p "${RELEASE_DIR}/roms" "${RELEASE_DIR}/config" "${RELEASE_DIR}/export"
cd "${RELEASE_DIR}"
export INTEGRAL_EMULATOR_GB_RUNTIME_DUAL_SERVER="${RESOURCES_DIR}/runtimes/gb/integral_gb_runtime_dual_server"
export INTEGRAL_EMULATOR_GB_RUNTIME_FIXED_HOST_RUNTIME="${RESOURCES_DIR}/runtimes/gb/integral_gb_runtime_fixed_host"
export INTEGRAL_EMULATOR_GB_RUNTIME_MOBILE_RUNTIME="${RESOURCES_DIR}/runtimes/gb/integral_gb_runtime_mobile_runtime"
export INTEGRAL_EMULATOR_N64_RUNTIME_HOME="${RESOURCES_DIR}/runtimes/n64"
exec "${RESOURCES_DIR}/client/integral_client" "$@"
